feat: TLS 종료 가능한 커스텀 서버 엔트리 (server.js) - #90
Merged
Conversation
adapter-node 의 기본 엔트리(`node build`)는 평문 HTTP 만 서빙한다. 리버스 프록시가 앞에 있으면 충분하지만, 그 계층이 없는 환경에서는 앱이 직접 TLS 를 끝내야 한다. IdP 는 브라우저가 직접 붙고 OIDC issuer 가 https 여야 하므로(ORIGIN/IDP_ISSUER_URL) 평문으로 서빙하면 로그인 흐름이 깨진다. - TLS_DIR 이 있으면 https, 없으면 평문 = **기존 동작 그대로**라 리버스 프록시 뒤의 배포에는 아무 영향이 없다. - TLS 는 fail-hard — 인증서를 못 읽으면 평문 폴백 없이 죽는다. TLS 로 뜨라고 지시했는데 조용히 평문으로 뜨는 것은 사고이고, IdP 는 그 경우 자격증명이 그대로 노출된다. - BUILD_TARGET=node 로 빌드했을 때만 의미가 있다. `node server.js` 로 실행한다. 검증 (BUILD_TARGET=node DB_DIALECT=postgres): - 빌드 성공, build/handler.js 생성 - fail-hard: 잘못된 TLS_DIR → exit=1, ENOENT .../tls.crt 로 기동 거부 - 평문: listening (plaintext) + /api/health 응답 - TLS: listening (TLS) + https 응답 + 같은 포트에 평문 접속 시 exit=52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
adapter-node 의 기본 엔트리(
node build)는 평문 HTTP 만 서빙한다. 리버스 프록시가 앞에있으면 충분하지만, ingress controller 나 프록시 계층이 없는 환경에서는 앱이 직접 TLS 를
끝내야 한다.
IdP 는 브라우저가 직접 붙고 OIDC issuer 가 https 여야 하므로(
ORIGIN/IDP_ISSUER_URL),평문으로 서빙하면 로그인 흐름이 깨진다.
변경
server.js하나 추가. adapter-node 의build/handler.js를http/https.createServer로 감싼다.TLS_DIR이 있으면 https, 없으면 평문 = 기존 동작 그대로라 리버스 프록시 뒤의 배포에는아무 영향이 없다.
지시했는데 조용히 평문으로 뜨는 것은 사고이고, IdP 는 그 경우 자격증명이 그대로 노출된다.
BUILD_TARGET=node로 빌드했을 때만 의미가 있다(cloudflare 어댑터는build/handler.js를만들지 않는다).
node server.js로 실행한다.검증
BUILD_TARGET=node DB_DIALECT=postgres기준:build/handler.js생성TLS_DIR→exit=1,ENOENT ... /tls.crt로 기동 거부listening (plaintext)+/api/health응답listening (TLS)+ https 응답 + 같은 포트에 평문 접속 시exit=52실제 배포(k8s, ingress 없는 클러스터)에서도
health=200, OIDC discovery 200,평문 443 접속 차단을 확인했다.